package rentcar.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import rentcar.domain.Request;
import rentcar.repository.RequestDao;
import rentcar.service.RequestService;

@Service
@Transactional
public class RequestServiceImpl implements RequestService {

	@Autowired
	private RequestDao requestRepository;

	@Override
	public void saveRequest(Request request) {
		requestRepository.save(request);
	}
	
	@Override
	public void deleteRequest(Request request) {
		requestRepository.delete(request);
	}
	
	@Override
	public void updateRequest(Request request) {
		requestRepository.update(request);
	}

	@Override
	public Request getRequestByID (long requestId) {
		
		return requestRepository.findById(requestId);
	}
	
	
	@Override
	public List<Request> getRequests() {
		
		List<Request> requests = requestRepository.findAll();		
		return requests;
	}

		
	
	
}
